import React, { PureComponent } from "react"
import Styles from '@/scss/froms.scss'
import CONSTS from "@/inits/consts"
const STATE = CONSTS.STATE
//引入mobx文件数据
import loginStore from "@/store/login_store"
//引入自己的工具包
import dateUtils from "@/utils/dateutils"
/* 这是用户任务操作日志渲染组件 */
class FromLog extends PureComponent<any, any>{

  //根据传入状态返回不同的操作结果
  returnUpdate = (state: string) => {
    switch (state) {
      case STATE.DONE:
        return "完成了任务"
      case STATE.UNDONE:
        return "重做了任务"
      case STATE.DELETE:
        return "把任务移到了回收站"
      case STATE.REDUCTION:
        return "从回收站恢复了任务"
      case STATE.CREATE:
        return "创建了任务"
      case CONSTS.FROMTYPE.UPDATE:
        return "更新了任务内容"
    }
  }

  render() {
    return (
      <div className={Styles.from_update}>
        {
            <ul>
              {
                this.props.updatetime.map(item => {
                  return (
                    <li key={item.updatetime}>{/*此处用户名如果添加登录功能后可以传入用户名变量  */}
                      <span>{loginStore.activeUser} {this.returnUpdate(item.updatestate)}</span>  <i>{dateUtils.getLocalTimeDate(item.updatetime)}</i>
                    </li>)
                })
              }
            </ul>
       }
      </div>
    )
  }
}


export default FromLog